/**
 * @author: Loy-winters1224@163.com
 * @date: 2014-8-21-下午3:56:28
 */
package net.loyintean.pearlshell.wechat.service;

import net.loyintean.pearlshell.wechat.common.MessageTypeEnum;
import net.loyintean.pearlshell.wechat.model.BaseMessageModel;
import net.loyintean.pearlshell.wechat.model.common.TextMessageModel;

/**
 * 
 * @author Loy-winters1224@163.com
 * @version 2014-8-21.1.0.0
 */
public class DefaultMessageProcesser implements IMessageProcesser {

	protected static final String lineSeparator = System
			.getProperty("line.separator");

	/**
	 * default process is return a TextMessageModel. it's content is provides by
	 * sub-class.
	 * 
	 * @author Loy-winters1224@163.com
	 * @see net.loyintean.pearlshell.wechat.service.IMessageProcesser
	 *      #process(net.loyintean.pearlshell.wechat.model.BaseMessageModel)
	 * 
	 */
	@Override
	public BaseMessageModel process(BaseMessageModel request) {
		assert request != null;

		TextMessageModel response = new TextMessageModel();

		response.setCreateTime(request.getCreateTime());

		// 注意这两个值是相反的
		response.setFromUserName(request.getToUserName());
		response.setToUserName(request.getFromUserName());

		response.setMsgType(MessageTypeEnum.text);

		response.setContent(getContent(request));

		return response;
	}

	protected String getContent(BaseMessageModel request) {
		return "不好意思，完全没听懂你在说什么。";
	}

}
